import {observable, action, extendObservable, isObservable} from 'mobx';
import { WeaBrowser} from 'ecCom';
import { toJS }  from 'mobx';

// import WeaTableMobx from 'comsMobx';
// const { comsWeaTableStore } = WeaTableMobx.store;

import * as API_WORKPLANSHAREPERSONALSTORE from '../../apis/workPlanSharePersonal';

import CommonStore from '../CommonStore';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
export default class WorkPlanSharePersonalStore extends CommonStore {
    test = getLabel(20190,'日程共享');
    @observable userList = [];

    constructor() {
        super();
        this.pageName = 'workPlanSharePersonal';
        //添加日程共享的保存的后台接口
        this.interfaceOfAddWPShare = null;

    }

    //存储添加日程共享的authfields
    @observable addWorkPlanShareCondition = [];

    //newtabkey表示切换tabs后的那个tabkey
    @action
    setAddWorkPlanShareConditionAndInterfaceOfAddWPShare(newtabkey) {

        if (newtabkey == "0") {

            this.interfaceOfAddWPShare = API_WORKPLANSHAREPERSONALSTORE.addPersonalDefaultShare;

            API_WORKPLANSHAREPERSONALSTORE.getPersonShareAuthField().then(action('fetchAuthFieldSuccess1', data => {
                this.addWorkPlanShareCondition= toJS(data);
            }))
        } else {

            this.interfaceOfAddWPShare = API_WORKPLANSHAREPERSONALSTORE.addCreateDefaultShare;

            API_WORKPLANSHAREPERSONALSTORE.getCreateShareAuthField().then(action('fetchAuthFieldSuccess2', data => {
                this.addWorkPlanShareCondition= toJS(data);
            }))
        }

    }

    doSave(data) {
        this.interfaceOfAddWPShare(data).then(action('afterSave', data => {
            this.doSearch()
            this.closeAddDialog()
        }))
    }

    @action
    addUser(params) {
    this.userList.push({name:"dyf"});
    }
    getUserList(params) {
    return this.userList.slice();
    }

}
